
{extend name=".././view/list.html" /}
{block name="jsset"}

{/block}
{block name="nav"}
<span class="layui-breadcrumb">
	<a href="">成绩采集</a>
	<a><cite>已录成绩</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item">
	<label for="searchval" class="layui-form-label">
		关键字
	</label>
	<div class="layui-input-block">
		<input type="text" id="searchval" name="searchval"
		autocomplete="off" class="layui-input" placeholder="按学生姓名查询">
	</div>
</div>
<div class="layui-form-item">
	<label for="subject_id" class="layui-form-label" style="height: 100%">学科</label>
	<div class="layui-input-block">
		<input type="radio" name="subject_id" title="无" value="" lay-skin="primary" lay-filter="subject" checked="true">
		{foreach $list.subject_id as $key=>$vo}
		<input type="radio" name="subject_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
		{/foreach}
	</div>
</div>
{/block}
{block name="table"}
<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="myjs"}
<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
<!-- 	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-danger" lay-event="dels">
			<i class="iconfont">&#xe69d;</i> 批量删除
		</button>
	</div> -->
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 表格操作 -->
<script>
	// 设置列
    options.cols=[[ //表头
    {type:'checkbox', fixed: 'left'},
    {field: 'kaoshi_id', title: '考试',sort: true, minWidth:180,templet:function(d){
    	var str ='';
    	if(d.kaoshi_title)
    	{
    		str = d.kaoshi_title;
    	}
    	return str;
    }},
    {field: 'school_id', title: '学校',sort: true, minWidth:70,templet:function(d){
    	var str ='';
    	if(d.school_jiancheng)
    	{
    		str = d.school_jiancheng;
    	}
    	return str;
    }},
    {field: 'banji_id', title: '班级',sort: true,templet:function(d){
    	var str='';
    	if(d.banji_title)
    	{
    		str = d.banji_title;
    	}
    	return str;
    }},
    {field: 'student_name', title: '姓名',sort: true},
    {field: "subject_id",title: '学科',sort: true,templet:function(d){
    	var str='';
    	if(d.subject_title)
    	{
    		str = d.subject_title;
    	}
    	return str;
    }},
    {field: 'defen', title: '得分', sort: true,minWidth:80,edit:'text'},
    {field: 'update_time', title: '修改时间', sort: true,minWidth:160},
    {field: 'status', title: '状态',templet:'#status', sort: true},
    {field: 'id', title: '操作',toolbar: '#barDemo',minWidth:70}
    ]];
	// 设置每页显示条数
	options.limit = 25;
	options.limits = [25,50,75,100];


    // 提交搜索条件后重载表格
    layui.use(['table','cjgl'],function(){
    	var table = layui.table
    	cjgl = layui.cjgl;
    	//表头工具栏事件
    	table.on('toolbar(mytable)', function(obj){
    		switch(obj.event){
    			case 'dels':
	    			var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
	    			cjgl.delAll(checkStatus,'/chengji/index/delete','mytable');
	    			break;
	    		};
	    	});

        //监听行工具条
        table.on('tool(mytable)', function(obj){
        	var data = obj.data; //获得当前行数据
        	var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        	var tr = obj.tr; //获得当前行 tr 的DOM对象
        	switch(layEvent){
        		case 'del':// 删除
        		cjgl.del(obj,"/chengji/index/delete");
        		break;
        	};
        });

        // 单元格编辑
        table.on('edit(mytable)',function(obj){
        	//声明变量
        	var newdefen = obj.value
        	,colname = obj.data.subject_lieming
        	,id = obj.data.kaohao_id;

	      	// 修改服务器数据
	      	$.ajax({
	      		url:"/luru/index/update/" + id,
	      		type:'PUT',
	      		data:{
	      			"colname": colname
	      			,"newdefen": newdefen
	      		},
	      		success:function(result){
	      			if(result.val == 0 || result.code==0)
	      			{
	      				layer.msg(result.msg,{icon:5});
	      			}else{
              }
            },
            error:function(result){
            	layer.msg('数据扔半道啦。',function(){});
            },
            });
	      })
    });
</script>
{/block}
